package com.njupt.towerinfos.controller;

import com.njupt.towerinfos.domain.PredTowerChecks;
import com.njupt.towerinfos.domain.TowercheckResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/tw")
@CrossOrigin("*")
public class CheckCtrl {
    @RequestMapping("/insertTowerCheck")
    public String addCheck(PredTowerChecks ptc) {
        return "{\n" +
                "    \"genCheck\": \"1234567\"\n" +
                "}";
    }

    @RequestMapping("/modTowerCheck")
    public String checkResult(TowercheckResult tcr){
        return "{\n" +
                "    \"checkres\": \"success\"\n" +
                "}";
    }

    @RequestMapping("/findCheckInfoByTowerid")
    public PredTowerChecks findCheck(String towerid) {
        return PredTowerChecks.builder().checkdate(new Date()).checker("张三").company("中铁十一局六公司")
                .manageid(5).towerid("tj1234563").markdate(new Date()).markname("无极")
                .result(TowercheckResult.builder().checkid("tj111").broken(1).clear(1).ladder(1)
                        .limiter(1).waterproof(1).resid(10).build()).build();
    }

    @RequestMapping("/delTowerCheck")
    public String delCheck(String checkid){
        return "{\n" +
                "    \"destroy\": \"success\"\n" +
                "}";
    }
}
